package cc.mrbird.febs.power.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.power.entity.OperateLogInfo;
import cc.mrbird.febs.power.service.IOperateLogInfoService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * @author MrBird
 */
@RestController
@RequestMapping("/power/operate-log-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class OperateLogInfoController {

    private final IOperateLogInfoService iOperateLogInfoService;

    /**
     * 分页查询
     * @param page
     * @param operateLogInfo
     * @return
     */
    @GetMapping("/page")
    public R getOperateByPage(Page page,OperateLogInfo operateLogInfo) {
        return R.ok(iOperateLogInfoService.page(page, Wrappers.<OperateLogInfo>lambdaQuery()
                .eq(operateLogInfo.getAccountCode()!=null,OperateLogInfo::getAccountCode,operateLogInfo.getAccountCode())
                .like(operateLogInfo.getOperateFunction()!=null,OperateLogInfo::getOperateFunction,operateLogInfo.getOperateType())
                .eq(operateLogInfo.getOperateType()!=null,OperateLogInfo::getOperateType,operateLogInfo.getOperateType())));
    }

    /**
     * 新增操作记录
     * @param operateLogInfo
     * @return
     */
    @PostMapping("/OperateLogInfoAdd")
    public R OperateLogInfoAdd(OperateLogInfo operateLogInfo) {
        return R.ok(iOperateLogInfoService.save(operateLogInfo));
    }

}
